Other command line utilities

The Resource Compiler

 

The resource compiler receives an .rc file as input that is written in a special language for describing resources. It will produce a binary file as output with the .res extension that can be used with the other object files by the linker to build an executable.

Usage:

lrc [options] .RC input file

Switches:

 

Option

Meaning

/r

Build a .res file. This is assumed, so this option is there just for compatibility with earlier versions of rc.

/v

Verbose output

/m

Build a map file. The name of the map file will be the same as the output file with a .map extension.

/dSYM

Define symbol. This is for Lrc's pre-processor.

/ofile

Write the output into <file>. No space should be left between the o and the name of the file.

/fo

Same as above.

/l

Default language number follows in hexadecimal.

/I

Add an include path.

/p

Print in the standard output a list of file dependencies of the given input resource file.

 

 

Flags are not case sensitive.

The resource compiler defines the symbol

            RC_INVOKED

To allow you conditional compilation of resources and to direct it to avoid much of the program text.

The pedump Utility

This utility has been the workhorse of lcc-win32. Without it, the linker and the debugger would not exist. To be able to generate something, you must be able to see what you are generating. See the technical documentation for more information about pedump.

Files types dumped are:

·EXE               Executable files

·OBJ               Object files

·RES               Resource files

·DLL               DLLs

·OCX              Type libraries+dlls

·LIB                Libraries

·TLB/OCA      Type libraries

·DBG              DLLs debug info

 

Option
Description

/A

Includes everything in the output. All sections, all data dumps, etc. The code sections will be disassembled and if debug information is available, the line numbers will be annotated in the resulting output.

/D

Dumps the code view or gcc debug information. This option supports the NB09 Standard from Microsoft, and the STABS format from gcc.

/E

Dump the resources section.

/EXP

If given an import library, pedump will generate a list of the exported functions in a format suitable for the buildlib utility. See FAQ question 12 for further explanation. If given a DLL, pedump will print a list of the exported symbols from the DLL, in the same format. If given an object file, this option will trigger pedump to print a list of all public symbols defined in the object file, in the same format.

/functionsize

Will produce a table of all functions defined in the object or executable file sorted by their size in bytes. The executable should have a symbol table (debug information should be present).

/H

Includes a hexadecimal dump of the sections in the file.

/HEX

Dump contents in hexadecimal form, without any concern for structures in the file. This allows you to dump any type of file.

/L

Includes line number information.

/OUT:file

Prints the output into <file> instead of standard output. If the given file name contains spaces it should be enclosed in quotes.

/REL

Shows the relocations.

/R

Shows the resources in an executable.

/SUMMARY

Shows the sizes for the main parts of the file only.

/S

Dumps the symbol table. All the symbols are dumped with all the details. Useful if you are writing a compiler.

/SP

Writes all the exported/imported symbols from an object file or executable. This is a smaller and more readable output than /S.

/T

Dumps a type library. This will be determined automatically if you present to pedump a library that contains an exported function like DllRegisterServer.

/X

Extracts a section to a file. The name of the section immediately follows the “x”. For instance /x.data will create a data.scn file with the contents of the data section.

F2C — The Fortran Compiler

 

SYNOPSIS

 f2c [option ... ] file ...

DESCRIPTION

F2c converts Fortran 77 source code in files with names ending in `.f' or `.F' to C source files in the current directory, with `.c' substituted for the final `.f' or `.F'.

 The lcc compiler is invoked if the compilation finished without error and an object file is generated in the current directory.

If no Fortran files are named, f2c reads Fortran from standard input and writes C on standard output.

File names that end with `.p' or `.P' are taken to be prototype files, as produced by option `-P', and are read first.

 

 The following options have the same meaning as in other Fortran compilers.

 -C Compiles code to check that subscripts are within declared array limits

 -Idir  Looks for a non-absolute include file first in the directory of the current input file, then in directories specified by -I options (one directory per option). Options -I2 and -I4 have precedence, thus a directory named 2 should be specified by -I./2.

 -onetrip  Compiles DO loops that are performed at least once if reached. (Fortran 77 DO loops are not performed at all if the upper limit is smaller than the lower limit.)

 -U Honors the case of variable and external names. Fortran keywords must be in lower case.

 -u Makes the default type of a variable `undefined' rather than using the default Fortran rules.

 -w Suppresses all warning messages, or if the option is `-w66', just Fortran 66 compatibility warnings.

 

 The following options are peculiar to f2c.

 -A Produces ANSI C. Default is old-style C. This option is not very useful with lcc-win32, but allows you to port the resulting C code to other machines.

 -a Makes local variables automatic rather than static unless they appear in a DATA, EQUIVALENCE, NAMELIST, or  SAVE statement.

 -C++ Outputs C++ code. This will make the resulting code incompatible with lcc-win32, and object file generation will not work. Again, this can be useful if you are porting the code to another machine or you want to link the resulting code with C++.

 -c Includes original Fortran source as comments.

 -cd Does not recognize cdabs, cdcos, cdexp, cdlog, cdsin, and cdsqrt as synonyms for the double complex intrinsics  zabs, zcos, zexp, zlog, zsin, and zsqrt, respectively.

 -ddir  Writes `.c' files in directory dir instead of the current directory.

 -E Declares uninitialized COMMON to be Extern (defined to be overwrite-capable in f2c.h as extern).

 -ec Places uninitialized COMMON blocks in separate files: COMMON /ABC/ appears in file abc_com.c. Option `-e1c'  bundles the separate files into the output file, with  comments that give an unbundling sed(1) script.

 -ext Complains about f77(1) extensions. This is useful if you want to remain compatible with Fortran 66, the standard of more than 30 years ago.

 -g Includes original Fortran line numbers in #line lines.

 -h Emulates Fortran 66's treatment of Hollerith: tries to align character strings on word (or, if the option is  `-hd', on double word) boundaries.

 -i90 Does not recognize the Fortran 90 bit-manipulation intrinsics btest, iand, ibclr, ibits, ibset, ieor, ior,  ishft, and ishftc.

 -kr Uses temporary values to enforce Fortran expression evaluation where K&R (first edition) parenthesization  rules allow rearrangement. If the option is `-krd',  uses double precision temporaries even for single-precision operands.

 -P  Writes a file.P of ANSI (or C++) prototypes for definitions in each input file.f or file.F. When reading  Fortran from standard input, writes prototypes at the  beginning of standard output. Option -Ps implies -P  and gives exit status 4; if rerunning f2c may change  prototypes or declarations.

 -p  Supplies preprocessor definitions to make common-block members look like local variables.

 -R Does not promote REAL functions and operations to DOUBLE  PRECISION. Option `-!R' confirms the default, which  imitates f77.

 -r Casts REAL arguments of intrinsic functions and values of REAL functions (including intrinsics) to REAL.

-r8 Promotes REAL to DOUBLE PRECISION, COMPLEX to DOUBLE COMPLEX.

 -s Preserves multidimensional subscripts. Suppressed by  option `-C' .

 -Tdir  Puts temporary files in directory dir.

 -w8 Suppresses warnings when COMMON or EQUIVALENCE forces odd-word alignment of doubles.

 -Wn Assumes n characters/word (default 4) when initializing numeric variables with character data.

 -z Does not implicitly recognize DOUBLE COMPLEX.

 -!bs Does not recognize backslash escapes in character strings.

 -!c Inhibits C output, but produces -P output.

 -!I Rejects include statements.

-!i8 Disallows INTEGER*8.

 -!it  Does not infer types of untyped EXTERNAL procedures from use as parameters to previously defined or prototyped  procedures.

 -!P Does not attempt to infer ANSI or C++ prototypes from usage.

 

Options specific to lcc-win32:

-removec Instructs f2c to remove the intermediate C file.

 

The resulting C invokes the support routines of f77; object code should be linked with lcclnk specifying libf77.lib at the end of the command line. Wedit will automatically add this library when any of the project files end with .f.

 

 SEE ALSO S. I. Feldman and P. J. Weinberger, `A Portable Fortran 77 Compiler', UNIX Time Sharing System Programmer's Manual, Tenth Edition, Volume 2, AT&T Bell Laboratories, 1990. This document is distributed with the source code of f2c. It is a file for the Laserjet printer. To print it you should open a command shell and issue the command: print f2c.prt.

 

FILES

f2c.h This file is used by the generated C code. It should be in the \lcc\include directory.

libf77.lib This file is the runtime of the Fortran system. It should be in the \lcc\lib directory with all other libraries.

f2c.exe The is the compiler itself. It should be located in the \lcc\bin directory together with all other executables.

 

DIAGNOSTICS

The diagnostics produced by f2c are intended to be self-explanatory. lcc-win32 will not generate any warnings when called from f2c. The resulting C file can be invalid, however, this provokes an error message from lcc-win32. This happens when you do not adhere to the prototypes given or you have an error in the calling sequence: you are calling a subroutine with different numbers of arguments within the same program. The error issued by lcc-win32 follows the warning of the Fortran compiler.

 

BUGS

Floating-point constant expressions are simplified in the floating-point arithmetic of the machine running f2c, so that they are typically accurate to, at most 16 or 17, decimal places.

Untypable EXTERNAL functions are declared int.

The browsegen Utility

 

This utility is a modified version of the compiler that will produce a browse file containing the position in the given source file or its included headers of the symbols used. The format of the generated browse files is described in the technical documentation. Use this utility only if you want to build browse information for use in another software. Normally, this utility is only used by the IDE (Wedit) to answer queries. A more detailed description of how it works is found in the technical documentation.

 

Browsegen accepts the following command line options:

 

·        showifdeflines. This will trigger line numbers of inactive lines to be printed in standard output or in the given output file. This is useful for finding out which lines in a source file are being compiled or not.

·        M1. This will show in the standard output all include files by the given input file.

·        Fo<file>. Writes all output in the given file. This is exactly the same as the compiler option Fo.

·        -P –P1 –P2 –P3 –P4. This generates a C source file that contains the public or public and private interface for the given source file.

 

Option

Description

-P or –P1

Will write all the prototypes for the public (i.e. not static) functions defined in the module.

-P2

Will write the public prototypes and data definitions for the given module.

-P3

Will write the prototypes for both the public and static functions, and the public data dependencies.

-P4

Will write the public and static function prototypes, and the public and static data definitions.

 

Note that only definitions at the global level will be written. Local or external variables will never be written.

The buildlib Utility

 

This utility reads an ASCII description of symbols and produces an import library that allows you to link your executable with a specific DLL.

It has no command line options and the input arguments are as follows:

 

buildlib <ASCII description> <output library>

 

The first argument has to be a text file that contains the list of symbols to be built into the library; the second argument is the name of the library.

 

Normally, the extension used in lcc-win32 for this textual description is .exp. See the directory \lcc\buildlib for numerous examples of these file types.

 

The format of the text file is as follows:

 

First line: Name of the DLL this import library should bind to. This is mandatory.

All other lines have a column format with 1 mandatory column and two optional columns.

 

The first column should contain the symbol name as emitted by the compiler, i.e., with all decorations, such as leading underscore, and '@nn' decoration for _stdcall symbols.

 

The second column is optional. It indicates the name of the symbol as it is exported from the DLL. This can be different from the decorated form.  For example, you may want to export a function without any decorations so that you can your DLL in other environments. If you omit this column, buildlib will strip decorations from the symbol names.

 

The third column is also optional, consisting of a single keyword 'data'. If present, this means that the exported symbol is not a function, but a data item, i.e., a variable.

The lcclib Utility

The purpose of this utility is to build library files (.lib) from a list of object files. The general format of the command line is:

 

lcclib <options>  <library file>  <object files >

 

Options:

Option

Meaning

/out:libfile.lib

Specifies the name of the output library file.

/extract:<object file>

Extracts the specified object file from the library.

/remove:<object file>

Removes the specified object file from the library.

/verbose

Progress report will be printed to standard output.

 

The Bind Utility

This program inspects a given object file and appends to it a list of imported functions. This list has the following format:

 

IMPORTS

CRTDLL.dll

_fprintf                   fprintf

USER32.dll

_LoadLibrary@4 LoadLibrary

...

$$END$$

 

In words: The list starts with the keyword ‘IMPORTS’, followed by a DLL list. Each DLL starts with the name, followed by the imported functions from that DLL in the object file.

 

Usage:

The syntax is:

bind <file name>

 

The argument should be the name of an existing object file.

 

The mergeasm utility

 

This utility will take an assembler file as generated by the compiler, and will merge it with the C source file. This needs that you instruct the compiler to generate debug information with the –g2 option. The usage is very simple :

 

mergeasm input.asm MergedOutput.asm

 

This will read the corresponding C input file and merge it with the assemble file input.asm, producing a merged « MergedOutput. asm » file.